package com.edu.koTA07.takingOrder;

//import java.util.Locale;

import android.app.Activity;
import android.os.Bundle;
import android.util.TypedValue;
import android.view.View;
import android.view.ViewGroup.LayoutParams;
import android.widget.LinearLayout;
import android.widget.TextView;
import android.widget.Toast;
//import com.app.login.*;
public class DisplayUser extends Activity
{
        @Override
		public void onCreate(Bundle savedInstanceState)
        {
                super.onCreate(savedInstanceState);
                //setContentView(R.layout.userinfo);


                @SuppressWarnings("unused")
				final String DB_name = "User";
                @SuppressWarnings("unused")
				final String TABLE_NAME = "tbl_users";
                @SuppressWarnings("unused")
				final int       DB_version = 1;
                //final  DatabaseHelper database_helper;
                //final SQLiteDatabase database_wr;


                /*
                database = openOrCreateDatabase(DB_name,SQLiteDatabase.CREATE_IF_NECESSARY, null);
		        database.setLocale(Locale.getDefault()); // Set the locale
		        database.setLockingEnabled(true); // SQLiteDatabase is made thread-safe by using locks around critical sections.
		        database.setVersion(1);
		
		        if(database.isOpen())
		        {
		                Toast.makeText(this, "Yes database is open",
						Toast.LENGTH_SHORT).show();
		        }
		        if(database.isDbLockedByCurrentThread())
		        {
		                Toast.makeText(this, "Yes database is locked",
						Toast.LENGTH_SHORT).show();
		        }
		        Cursor c = database.query(TABLE_NAME, null, null, null, null,null,null);
		
		        LogIn login = new LogIn();
		        login.LogCursorInfo(c);
                c.close();
                */

                //LogIn login = new LogIn();
                //database_wr = login.database_helper.getWritableDatabase();
                String username= getIntent().getStringExtra("username");
                String password= getIntent().getStringExtra("password");

                Toast.makeText(this, username, Toast.LENGTH_SHORT).show();

                View infoPanel = _createInfoPanel(username,password);
                setContentView(infoPanel);


        }
        public View _createInfoPanel(String username,String password)
        {
                LinearLayout panel = new LinearLayout(this);
                panel.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT));
                panel.setOrientation(LinearLayout.VERTICAL);

          // user id
                TextView Welcome = new TextView(this);
                Welcome.setText("Welcome "+username);
                Welcome.setTextSize(TypedValue.COMPLEX_UNIT_SP, 14f);
                Welcome.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));

                TextView UserName = new TextView(this);
                UserName.setText("Firstname:"+username);
                UserName.setTextSize(TypedValue.COMPLEX_UNIT_SP, 14f);
                UserName.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));

                TextView Password = new TextView(this);
                Password.setText("Lastname:"+password);
                Password.setTextSize(TypedValue.COMPLEX_UNIT_SP, 14f);
                Password.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));

                panel.addView(Welcome);
                panel.addView(UserName);
                panel.addView(Password);
                return panel;
        }
}
